<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct(){
		parent::__construct();
		$this->load->library('session');
		//		$this->load->helper('cookie');
		//		$this->session->set_userdata('user_email','');
		$this->load->library("my_layout");
		$this->load->helper('form');
		$this->my_layout->setLayout("layout/layout");
//		$this->load->model('member_model');
		//		$this->my_layout_diary->setLayout("layout/layout_diary");
	}
	private $limit = 24;
	public function index(){
		$this->load->model('danhba_cat_model');
		$danhba['danhba'] = $this->danhba_cat_model->getAllDanhBa();
		$this->my_layout->view('index',$danhba);
	}
	public function getDanhBaById($ref=NULL,$offset=null){
		$this->load->library('pagination');
		$this->load->helper('url');
		$this->load->model('danhba_model');
		$data['danhba'] = $this->danhba_model->get_paged_list($this->limit,$offset,$ref);
		//Set Config Pagination
		$config['base_url'] = site_url('welcome/getDanhBaById/'.$ref.'/');
		$total = $this->danhba_model->count_AllById($ref);
 		$config['total_rows'] = $total['0']['total'];
 		$config['per_page'] = $this->limit;
		
		$config['uri_segment'] = 3;
		$this->pagination->initialize($config);	
		$this->my_layout->view('danhba',$data);

	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */